define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            var ids = Fast.api.query('ids');
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: `depot.storage.product/index?ids=${ids}`,
                    add_url: 'depot.storage.product/add',
                    edit_url: 'depot.storage.product/edit',
                    del_url: 'depot.storage.product/del',
                    multi_url: 'depot.storage.product/multi',
                    import_url: 'depot.storage.product/import',
                    table: 'depot_storage_product',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {field: 'id', title: __('Id')},
                        {field: 'productproduct.name', title: __('Product'), operate: 'LIKE'},
                        {field: 'nums', title: __('Nums')},
                        {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        {field: 'total', title: __('Total'), operate:'BETWEEN'},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
